主题
base64字符串转为图片 - Base64ToImage
函数简介
将Base64编码的图片数据转换为图片对象。
接口名称
Base64ToImageDLL调用
long Base64ToImage(long ola, string base64_str);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| base64_str | 字符串 | Base64编码的图片数据字符串,支持PNG、JPG、BMP等格式 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.Base64ToImage("value");csharp
using OLAPlug;
var ola = new OLAPlugServer();
long handle = ola.Base64ToImage("value");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
handle = ola.Base64ToImage("value")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long handle = ola.Base64ToImage("value");cpp
var ola = com("OlaPlug.OlaSoft")
var handle = ola.Base64ToImage("value")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
handle = ola.Base64ToImage("value")text
.局部变量 ola, OLAPlug
ola.创建 ()
handle = ola.Base64ToImage("value")aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var handle = ola.Base64ToImage("value");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 handle = ola.Base64ToImage("value")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long handle = ola.Base64ToImage("value");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
Base64ToImage(instance, "value");csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long Base64ToImage(long ola, string base64_str);
long instance = CreateCOLAPlugInterFace();
Base64ToImage(instance, "value");python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.Base64ToImage(instance, "value")返回值
长整数型:成功返回图片句柄,失败返回0。
注意事项
- 返回的图片需调用 FreeImagePtr 释放内存。
- Base64字符串必须是有效的图片数据编码。
